package 字节码文件.对象创建与访问指令;

import java.io.File;

/**
 * <P> @Author: ideaAdmin
 * <P> TODO: Class
 * <P> TODO: 对象的创建指令
 * <P> Date: 2022/3/27:13:25
 * <P> Description:
 */

public class NewTest {
    /**
     * TODO:对象的创建指令
     **/
    public void newInstance(){
        Object obj = new Object();

        File file = new File("atguigu.avi");
    }


    public void newArray(){
        int[] intArray = new int[10];
        double[]doubleArray = new double[10];
        Object[] objArray = new Object[10];
        int[][] mintArray = new int[10][10];
        String[][] strArray = new String[10][];
    }

    /**
        * TODO:字段访问指令
    **/

    public void sayHello(){
        System.out.println("hello");
        //TODO 0 getstatic #8 <java/lang/System.out : Ljava/io/PrintStream;>
        //TODO 3 ldc #9 <hello>
        //TODO 5 invokevirtual #10 <java/io/PrintStream.println : (Ljava/lang/String;)V>
        //TODO 8 return
        // TODO 获得静态变量out存入操作数栈
        // TODO 取出hello 放入操作数栈
        // TODO 调用方法 静态变量out和hello都出栈
    }

    public void setOrderField(){
        Order order = new Order();
        order.id = 1001;
        System.out.println(order.id);

        Order.name = "ORDER";
        System.out.println(Order.name);
    }

    /**
        * TODO:3.数组操作指令
    **/
    public void setArray(){
        int[] intArray = new int[10];
        intArray[3] = 20;
        System.out.println(intArray[1]);

//        boolean[] arr = new boolean[10];
//        arr[1] = true;

    }

    public void arrLength(){
        double[] arr = new double[10];
        System.out.println(arr.length);
    }

    /**
        * TODO:4.类型检查指令
    **/
    public String checkCast(Object obj){
        if(obj instanceof  String){
            return (String) obj;
        }else {
            return null;
        }
    }


}

class Order{
    int id;
    static  String name;
}
